package com.gpf.marketing.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gpf.marketing.mapper.CustIssuesMapper;
import com.gpf.marketing.pojo.entity.CustIssues;
import com.gpf.marketing.pojo.vo.AdvMaVo;
import com.gpf.marketing.pojo.vo.CusIssVo;
import com.gpf.marketing.service.CustIssuesService;
import com.seventh.common.pojo.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: clms-fifth
 * @description: 客服问答业务层
 * @author: 龚鹏飞
 * @create: 2021-07-21 18:33
 **/
@Service
public class CustIssuesServiceImpl implements CustIssuesService {

    @Resource
    private CustIssuesMapper customerIssuesMapper;


    @Override
    public R selectCustIssues(Integer currentPage,Integer pageSize, CusIssVo cusIssVo) {
        Page<CustIssues> page=new Page<>(currentPage,pageSize);
        QueryWrapper<CustIssues> wrapper=new QueryWrapper<>();
        if (StringUtils.isNotEmpty(cusIssVo.getSubmodule())){
            wrapper.like("submodule",cusIssVo.getSubmodule());
        }
        customerIssuesMapper.selectPage(page,wrapper);
        return R.ok().put("records",page.getRecords()).put("total",page.getTotal());
    }

    @Override
    public R insertCustIssues(CustIssues custIssues) {
        int i=customerIssuesMapper.insert(custIssues);
        return (i>0)? R.ok():R.error();
    }

    @Override
    public R updateCustIssues(CustIssues custIssues) {
        int i=customerIssuesMapper.updateById(custIssues);
        return (i>0)? R.ok():R.error();
    }

    @Override
    public R deleteById(Integer id) {
        int i=customerIssuesMapper.deleteById(id);
        return (i>0)? R.ok():R.error();
    }

    @Override
    public R selectById(Integer id) {
        CustIssues custIssues=customerIssuesMapper.selectById(id);
        return R.ok().put("custIssues",custIssues);
    }
}
